//
// Created by edward on 23-3-17.
//

#ifndef LEARNOPENGL_TEXTURE_H
#define LEARNOPENGL_TEXTURE_H

#include "stb_image.h"
#include <string>
#include "glad/glad.h"
#include <GLFW/glfw3.h>
#include <unordered_map>

class Shader;

class Texture {
public:
    enum class Type {
        JPG,
        PNG
    };
    enum class Wrap {
        REPEAT,
        MIRRORED_REPEAT,
        CLAMP_TO_EDGE,
        CLAMP_TO_BORDER
    };
    enum class Filter {
        LINEAR,
        NEAREST
    };
    explicit Texture(const std::string &path, const std::string &name = "texture", Filter f = Filter::LINEAR, Wrap w = Wrap::REPEAT);
    ~Texture() = default;

    void use(Shader *shader, unsigned unit = 0);

private:
    unsigned int id_;
    std::string name_;
    static std::unordered_map<std::string, unsigned int> mp;    //avoid being reloaded
};


#endif //LEARNOPENGL_TEXTURE_H
